<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="../../../common/taglib.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<sfa:mainTitle></sfa:mainTitle>
		<%@ include file="../../../common/meta.jsp"%>
<style type="text/css">
#title { 
	display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    width: 70px; } 
</style>		
		<script type="text/javascript">

	
$(function() {
	$(".delTrain").click(function() {
		var trainID = $(this).attr("val");
		var url = "${path}/productandtrain/lecturer/index/del/" + trainID;
		art.dialog( {
			lock : true,
			content : '确定要删除吗?',
			ok : function() {
				art.dialog( {
					id : "loading",
					lock : true,
					drag : false,
					resize : false,
					title : "正在删除..."
				});
				$.post(url, null, function(result) {
					art.dialog( {
						id : 'loading'
					}).close();//关闭等待框
						if (result == "true") {
							art.dialog( {
								icon : "succeed",
								content : "删除成功!",
								lock : true,
								ok : function() {
									location.reload();
								}
							});
						} else {
							art.dialog( {
								icon : "error",
								content : "删除失败!",
								lock : true,
								ok : true
							});
						}

					});

				return true;
			},
			cancelVal : '关闭',
			cancel : true
		//为true等价于function(){}
				});
	});
	$(".sumonTrain").click(function() {
		var saletrantakeid = $(this).attr("val");//获取当前下的属性val值
			var url = "${path}/productandtrain/lecturer/index/upd/" + saletrantakeid;
			$.get(url, null, function(result) {
				var j = $("<span>" + result + "</span>").html();
				var obj = eval("(" + j + ")");

				var temp = $("<div><div id='showWindow'>"
						+ $("#hidWindow").html() + "</div></div>");
				temp.find(".joinCount").html(obj.joinCount);
				temp.find(".gradeCount").html(obj.gradeCount);
				temp.find(".gradeAvg").html(obj.gradeAvg);
				temp.find(".hidtakeId").val(obj.saletrantakeid);
				art.dialog( {
					lock : true,
					ok : function() {
						art.dialog( {
							id : "loading",
							lock : true,
							drag : false,
							resize : false,
							title : "正在总结..."
						});
						var url1 = "${path}/productandtrain/lecturer/index/updsum";
						var data = {
							saletrantakeid : $("#showWindow .hidtakeId").val(),
							sumup : $("#showWindow .sumupText").val(),
							trainsort : $("#showWindow .gradeAvg").html()
						};

						$.post(url1, data, function(result) {
							art.dialog( {
								id : 'loading'
							}).close();//关闭等待框
								if (result == "true") {
									art.dialog( {
										icon : "succeed",
										content : "总结成功!",
										lock : true,
										ok : function() {
											location.reload();
										}
									});
								} else {
									art.dialog( {
										icon : "error",
										content : "总结失败!",
										lock : true,
										ok : true
									});
								}

							});

						return true;
					},
					cancel : "关闭"
				}).content(temp.html());

			});

		});
	$(".issueTrain").click(function() {
		var TrainID = $(this).attr("val");
		art.dialog( {
			lock : true,
			content : '确定?',
			ok : function() {
				art.dialog( {
					id : "loading",
					lock : true,
					drag : false,
					resize : false,
					title : "正在提交..."
				});
				$.ajax( {
					url : "${path}/productandtrain/lecturer/index/issue/" + TrainID,
					type : 'POST',
					timeout : 1000,
					error : function() {
						art.dialog( {
							id : 'loading'
						}).close();//关闭等待框 
					art.dialog( {
						icon : "error",
						content : "错误!请联系管理员",
						lock : true,
						ok : true
					});
				},
				success : function(result) {
					art.dialog( {
						id : 'loading'
					}).close();//关闭等待框 
					if (result == "true") {
						art.dialog( {
							icon : "succeed",
							content : "已完成",
							lock : true,
							ok : function() {
								location.reload();
							}
						});
					} else {
						art.dialog( {
							icon : "error",
							content : "失败!",
							lock : true,
							ok : true
						});
					}
				}
				});
				return true;

			},
			cancelVal : '关闭',
			cancel : true
		});

	});
});

$(function() { 
	$("#add").click(function() {
		document.form1.submit();
	});
})
</script>
	</head>
	<body id="master">
		<sfa:mainHeader></sfa:mainHeader>
		<div id="hidWindow" style="display: none;">
			<div class="sumupDiv">
				<table  cellspacing="0" cellpadding="0">
					<tr>
						<th>
							参加人数:
						</th>
						<td>
							<span class="joinCount"></span>
						</td>
					</tr>
					<tr>
						<th>
							评分人数:
						</th>
						<td>
							<span class="gradeCount"></span>
						</td>
					</tr>
					<tr>
						<th>
							平均分:
						</th>
						<td>
							<span class="gradeAvg"></span>
						</td>
					</tr>
					<tr>
						<th>
							总结:
						</th>
						<td>
							<input type="text" class="sumupText" />
							<input type="hidden" class="hidtakeId" />
						</td>
					</tr>
				</table>
			</div>
		</div>
		<form method="get">
			<div class="webpart3 contentarea">
				<div class="webpart-head">
					<div class="webpart-head-item">
						培训管理
						<div class="tools-btn">
							<a href="#" onclick="location.href='${path}/productandtrain/lecturer/index/add'"><span>
									<img src="${path}/statics/images/add2.gif"
										style="margin-right: 4px; margin-bottom: -3px;"
										 />新
									建</span> </a>
						</div>
					</div>
				</div>
				<div class="webpart-main" id="maindiv">
					<div class="webpart-main-item" style="padding-top: 12px;">
						<div class="search">
							<table cellpadding="0" cellspacing="0">
								<tr>
									<th>
										<span>培训标题</span>
									</th>
									<td>
										<input type="text" name="trainTitle" id="trainTitle"
											class="input-txt" value="${trainTitle}">
									</td>
									
									<th>
										<span>培训类型</span>
									</th>
									<td>
										<sfa:dic showType="select" kindNo="TRAINTYPE"
											code="${trainType}" def="ALL:全部;" attr="class='input-txt'"
											name="trainType" id="trainType"></sfa:dic>

									</td>
									<th>
										<span>培训开始日期</span>
									</th>
									<td>
										<input id="trianstartdate" name="trianstartdate" type="text"
											onClick="WdatePicker()" class="Wdate inputbox"
											readOnly="true" value="${trianstartdate}" />
									</td>
									<td>
										<input type="submit" class="linkbtn2" value="查询" />									
									</td>
								</tr>
								<tr>
								 <th>
										<span>所属机构</span>
									</th>
									<td>
										<select class="input-txt" name="branchId" id="branchId">
											<option value="ALL">
												全部
											</option>
											<c:forEach items="${BranchList}" var="branch">
												<option value="${branch.branchId }"
													<c:if test="${branchId==branch.branchId }">selected='selected'</c:if>>
													${branch.branchName}
												</option>
											</c:forEach>
										</select>
									</td>
									<th>
										<span>培训状态</span>
									</th>
									<td>
										<sfa:dic showType="select" kindNo="TRAINSTATUS"
											code="${trainStatus}" def="ALL:全部;" attr="class='input-txt'"
											name="trainStatus" id="trainStatus"></sfa:dic>
									</td>
									<th>
									</th>
									<td></td>
									<td> 
										<input type="button" class="linkbtn2" value="清空"
											onclick="location.href='${path}/productandtrain/lecturer/index';" />
									</td>
								</tr>
							</table>
						</div>
						<table id="mytable" cellpadding="0" cellspacing="0"
							class="dg_borderstyle  trStyleTable"
							style="margin-top: 0px; text-align: center;">
							<tr>
								<th>
									<span>序号</span>
								</th>
								<th>
									<span>培训类型</span>
								</th>
								<th>
									<span>标题</span>
								</th>
								<th>
									<span>培训开始时间</span>
								</th>
								<th>
									<span>讲师</span>
								</th>
								<th>
									<span>所属机构</span>
								</th>
								<th>
									<span>报名人数</span>
								</th>
								<th>
									<span>状态</span>
								</th>
								<th>
									<span>操作</span>
								</th>
							</tr>
							<c:forEach items="${pagination.resultList}" var="train" varStatus="ind" >
								<tr >
									<td width="10">
										 ${(pagination.page-1)*10+(ind.index+1)}
									</td>
									<td >
										<span>${train.traintypename}</span>
									</td>
									<td width="70">
										<a  id="title"
											href="${path}/productandtrain/lecturer/index/detail/${train.saletrantakeid}"
											target="_blank" title="${train.trainItem}">${train.trainItem}</a>
									</td>

									<td>
										<span><fmt:formatDate value="${train.trainstartdate}"
												pattern="yyyy-MM-dd" /> </span>
									</td>
									<td>
										<span>${train.trainername}</span>
									</td>
									<td width="75">
										<div style="display: block;overflow: hidden;text-overflow: ellipsis;
										 white-space: nowrap;width: 75px;" title="${train.branchname}">
										${train.branchname}
										</div>
									</td>
									<td>
										<span>${train.joincount}</span>
									</td>
									<td >
										<span>${train.statusname}</span>
									</td >
									<td style="max-width: 120px;min-width: 110px;" width="120">
										<a class="delTrain" href="javascript:void(0);"
											val="${train.saletrantakeid}" >删除</a>
										<c:if test='${train.trainstatus=="TRAINSTATUS_02"}'>
											<span class="v_line ">| </span>
											<a class="finishAffair"
												href="${path}/productandtrain/lecturer/index/into/${train.saletrantakeid}">导入学员</a>
										</c:if>
										<c:if test='${train.trainstatus=="TRAINSTATUS_00"}'>
											<span class="v_line finish_${train.saletrantakeid}">|</span>
											<a class="issueTrain finish_${train.saletrantakeid}"
												href="javascript:void(0)" val="${train.saletrantakeid}">
												发布 </a>
										</c:if>
										
										<c:if test='${train.trainstatus=="TRAINSTATUS_05"}'>
											<span class="v_line ">| </span>
											<a class="sumonTrain" href="javascript:void(0)"
												val="${train.saletrantakeid}">总结</a>
										</c:if>
										<c:if test='${train.trainstatus != "TRAINSTATUS_05" && train.trainstatus != "TRAINSTATUS_06" }'>
										| <a class="finishAffair"
												href="${path}/productandtrain/lecturer/index/edit/${train.saletrantakeid}">修改</a>
													</c:if>
									</td>
								</tr>
							</c:forEach>
						</table>
						<c:if test="${not empty pagination.multiPage}">
								<div class="dg_pagerstyle">
						<div class="pageinfo">
							   第${pagination.page }页 | 共${pagination.totalPages}页/${pagination.totalRows}条记录
						</div>
						<div class="pagebtn">
							${pagination.multiPage}
						</div>
					</div>	
						</c:if>
					</div>
				</div>
				<div class="webpart-foot">
					<div class="webpart-foot-item">
					</div>
				</div>
			</div>
		</form>
		<sfa:mainFooter></sfa:mainFooter>
	</body>
</html>